#! /usr/bin/python

MAX = 10**6

f = open("network.txt", "r")
matrix = []

total = 0
for i in range(40):
    s = f.readline().split(',')
    matrix.append([])
    for j in range(len(s)):
	if s[j] == '': break
	if s[j] == '-' or s[j] == '-\r\n':
	   matrix[i].append(MAX) 
        elif s[j] != '\r\n': 
	     matrix[i].append(int(s[j]))
	     total += int(s[j])

f.close()

total /= 2
print total
	
visited = set()
count = 0
cost = 0
visited.add(0)
edges = set()

print visited
while(count < 40):
    minimal = MAX
    for row in visited:        
	for j in range(40):
	    if j not in visited and matrix[row][j] < minimal:
		minimal = matrix[j][row]
		mj = j
	#print minimal
    visited.add(mj)
    print visited
    count += 1
    cost += minimal

print total - (cost - MAX)
        

